Search in sources :

Example 1 with Packet

use of org.openhab.binding.smarthomatic.internal.packetData.Packet in project openhab1-addons by openhab.

the class SmarthomaticBinding method activate.

/**
     * activate binding
     *
     */
@Override
public void activate() {
    // log activate of binding
    if (baseStation != null) {
        logger.info("Smarthomatic Binding activated. BaseStation= {}", baseStation.toString());
    }
    Bundle bundle = SmarthomaticActivator.getContext().getBundle();
    URL fileURL = bundle.getEntry("packet_layout.xml");
    Packet packet = null;
    try {
        InputStream inputStream = fileURL.openConnection().getInputStream();
        JAXBContext jaxbContext = JAXBContext.newInstance(Packet.class);
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        packet = (Packet) jaxbUnmarshaller.unmarshal(inputStream);
    } catch (IOException e1) {
        e1.printStackTrace();
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    this.packet = packet;
}
Also used : Packet(org.openhab.binding.smarthomatic.internal.packetData.Packet) Bundle(org.osgi.framework.Bundle) InputStream(java.io.InputStream) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) IOException(java.io.IOException) Unmarshaller(javax.xml.bind.Unmarshaller) URL(java.net.URL)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 Packet (org.openhab.binding.smarthomatic.internal.packetData.Packet)1 Bundle (org.osgi.framework.Bundle)1