这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bundles/action/org.openhab.action.astro/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Bundle-ManifestVersion: 2
Bundle-Description: This is the Astro action of the open Home Aut
omation Bus (openHAB)
Import-Package: org.apache.commons.lang.builder,
org.openhab.binding.astro.internal.calc,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bundle must not import internal packages from other bundles.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely right and we should change this (out of the scope of this Bugfix). What i changed was simply removing the require-bundle deep and add the import-package instead. @gerrieg could you please take care of this and create another PR moving the externally required classes in the appropriate package?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see issue #2969

org.openhab.binding.astro.internal.model,
org.openhab.core.items,
org.openhab.core.library.items,
org.openhab.core.library.types,
Expand All @@ -25,4 +27,3 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/action.xml
Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy
Require-Bundle: org.openhab.binding.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ Bundle-Activator: org.openhab.action.homematic.internal.HomematicActivator
Bundle-ManifestVersion: 2
Bundle-Description: This is the Homematic action of the open Home Aut
omation Bus (openHAB)
Import-Package: org.openhab.core.items,
Import-Package: org.openhab.binding.homematic.internal.common,
org.openhab.binding.homematic.internal.communicator.client,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bundle must not import internal packages from other bundles!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely right and we should change this (out of the scope of this Bugfix). What i changed was simply removing the require-bundle deep and add the import-package instead. @gerrieg could you please take care of this and create another PR moving the externally required classes in the appropriate package?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there shouldn't even a dependency from an action bundle to a binding bundle at all. The shared code should rather be externalized into an io bundle as it is e.g. done for squeezebox.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaikreuzer is it true that an action bundle should not depend on a binding bundle even in the case where its actions functioning are intentionally dependent on a properly configured and running binding, where each action call's first parameter is an item bound to the binding?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where each action call's first parameter is an item bound to the binding?

This imho mixes actions and bindings too heavily. An action should never really refer to an item where you need to know that a specific binding is configured to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see issue #2969

org.openhab.binding.homematic.internal.communicator.client.interfaces,
org.openhab.core.items,
org.openhab.core.library.items,
org.openhab.core.library.types,
org.openhab.core.scriptengine.action,
Expand All @@ -24,4 +27,3 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/action.xml
Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy
Require-Bundle: org.openhab.binding.homematic;bundle-version="1.5.0"
6 changes: 3 additions & 3 deletions bundles/action/org.openhab.action.mios/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ Bundle-Activator: org.openhab.action.mios.internal.MiosActivator
Bundle-ManifestVersion: 2
Bundle-Description: This is the MiOS action of the open Home Aut
omation Bus (openHAB)
Import-Package: org.openhab.core.items,
Import-Package: org.eclipse.xtext.xbase.lib,
org.openhab.binding.mios,
org.openhab.core.items,
org.openhab.core.library.items,
org.openhab.core.library.types,
org.openhab.core.scriptengine.action,
org.openhab.core.types,
org.eclipse.xtext.xbase.lib,
org.osgi.framework,
org.osgi.service.cm,
org.osgi.service.component,
Expand All @@ -25,4 +26,3 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/action.xml
Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy
Require-Bundle: org.openhab.binding.mios;bundle-version="1.7.0"
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Import-Package: org.apache.commons.io;version="2.0.1",
org.openhab.core.library.types,
org.openhab.core.scriptengine.action,
org.openhab.core.types,
org.openhab.io.squeezeserver,
org.osgi.framework,
org.osgi.service.cm,
org.osgi.service.component,
Expand All @@ -25,5 +26,4 @@ Bundle-DocURL: http://www.openhab.org
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Service-Component: OSGI-INF/action.xml
Bundle-ClassPath: .
Require-Bundle: org.openhab.io.squeezeserver;bundle-version="1.4.0"
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ Bundle-ManifestVersion: 2
Bundle-Description: This is the TinkerForge action of the open Home Aut
omation Bus (openHAB)
Import-Package: org.apache.commons.lang,
org.openhab.core.scriptengine.action,
org.openhab.binding.tinkerforge.ecosystem,
org.openhab.binding.tinkerforge.internal.model,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bundle must not import internal packages from other bundles!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely right and we should change this (out of the scope of this Bugfix). What i changed was simply removing the require-bundle deep and add the import-package instead. @theoweiss could you please take care of this and create another PR moving the externally required classes in the appropriate package?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there shouldn't even a dependency from an action bundle to a binding bundle at all. The shared code should rather be externalized into an io bundle as it is e.g. done for squeezebox.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, true … there are two options: a) remove the Action from the Designer due to this flaw or b) accept it for now, fix this issue and work on it afterwards

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am aware that it was not introduced by this PR and thus should also not block this PR. I just wanted to mention that there is a problem that should not have been merged in the first place and I hope there is already an existing issue entry to "work on it afterwards" - otherwise things tend to never get fixed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, see #2968

org.openhab.core.items,
org.openhab.core.library.items,
org.openhab.core.library.types,
org.openhab.core.scriptengine.action,
org.openhab.core.types,
org.osgi.framework,
org.osgi.service.cm,
Expand All @@ -25,5 +27,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Service-Component: OSGI-INF/action.xml
Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy
Require-Bundle: org.openhab.binding.tinkerforge;bundle-version="1.7.0",
org.eclipse.emf.ecore
Require-Bundle: org.eclipse.emf.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ Service-Component: OSGI-INF/binding.xml, OSGI-INF/genericbindingprovider.xml
Bundle-ClassPath: lib/commons-beanutils-1.8.3.jar,
.
Require-Bundle: org.openhab.io.rest.lib
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ Bundle-DocURL: http://www.openhab.org
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/homematicbinding.xml, OSGI-INF/genericbindingprovider.xml
Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Service-Component: OSGI-INF/activebinding.xml,
OSGI-INF/genericbindingprovider.xml
Bundle-ClassPath: .,
lib/async-http-client-1.8.4.jar
Bundle-ActivationPolicy: lazy
1 change: 1 addition & 0 deletions bundles/io/org.openhab.io.harmonyhub/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Bundle-ClassPath: .,
lib/smack-tcp-4.0.2.jar,
lib/harmony-java-client-1.0.3.jar,
lib/xpp3-1.1.4c.jar
Bundle-ActivationPolicy: lazy
17 changes: 10 additions & 7 deletions bundles/io/org.openhab.io.myopenhab/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
Manifest-Version: 1.0
Private-Package: org.openhab.io.myopenhab.internal
Ignore-Package: org.openhab.io.myopenhab.internal
Bundle-ManifestVersion: 2
Bundle-License: http://www.eclipse.org/legal/epl-v10.html
Bundle-Name: my.openHAB Service Connection Bundle
Bundle-SymbolicName: org.openhab.io.myopenhab
Bundle-Vendor: openHAB.org
Bundle-Version: 1.8.0.qualifier
Bundle-Activator: org.openhab.io.myopenhab.internal.MyOpenHABServiceActivator
Service-Component: OSGI-INF/myopenhab.xml
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ManifestVersion: 2
Bundle-Description: This is the my.openHAB IO bundle of the open Home Aut
omation Bus (openHAB)
Import-Package: org.apache.commons.io,
org.apache.commons.lang,
org.eclipse.emf.common.notify,
Expand All @@ -25,6 +27,7 @@ Import-Package: org.apache.commons.io,
org.openhab.core.library.types,
org.openhab.core.persistence,
org.openhab.core.scriptengine,
org.openhab.core.scriptengine.action,
org.openhab.core.service,
org.openhab.core.types,
org.openhab.model.core,
Expand All @@ -35,12 +38,12 @@ Import-Package: org.apache.commons.io,
org.osgi.service.cm,
org.osgi.service.event,
org.slf4j
Export-Package: org.openhab.io.myopenhab
Bundle-DocURL: http://www.openhab.org
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Service-Component: OSGI-INF/myopenhab.xml
Bundle-ClassPath: .,
lib/Java-WebSocket-1.3.0.jar,
lib/socket.io-client-0.4.3-SNAPSHOT.jar,
lib/engine.io-client-0.4.2-SNAPSHOT.jar,
lib/json-20140107.jar
Bundle-Vendor: openHAB.org
Require-Bundle: org.openhab.core.scriptengine

Bundle-ActivationPolicy: lazy
14 changes: 11 additions & 3 deletions bundles/io/org.openhab.io.myopenhab/OSGI-INF/myopenhab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@
http://www.eclipse.org/legal/epl-v10.html

-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" name="org.openhab.io.myopenhab">
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" deactivate="deactivate" immediate="true" name="org.openhab.io.myopenhab">
<implementation class="org.openhab.io.myopenhab.internal.MyOpenHABServiceImpl"/>

<service>
<provide interface="org.openhab.io.myopenhab.MyOpenHABService"/>
<provide interface="org.osgi.service.cm.ManagedService" />
<provide interface="org.openhab.core.scriptengine.action.ActionService" />
<provide interface="org.openhab.core.persistence.PersistenceService"/>
</service>
<reference bind="setItemUIRegistry" cardinality="1..1" interface="org.openhab.ui.items.ItemUIRegistry" name="ItemUIRegistry" policy="dynamic" unbind="unsetItemUIRegistry"/>
<reference bind="setEventPublisher" cardinality="0..1" interface="org.openhab.core.events.EventPublisher" name="EventPublisher" policy="dynamic" unbind="unsetEventPublisher"/>

<property name="service.pid" type="String" value="org.openhab.myopenhab"/>
<property name="event.topics" type="String" value="openhab/*"/>

<reference bind="setItemUIRegistry" cardinality="1..1"
interface="org.openhab.ui.items.ItemUIRegistry" name="ItemUIRegistry"
policy="dynamic" unbind="unsetItemUIRegistry"/>
<reference bind="setEventPublisher" cardinality="0..1"
interface="org.openhab.core.events.EventPublisher" name="EventPublisher"
policy="dynamic" unbind="unsetEventPublisher"/>

</scr:component>
7 changes: 3 additions & 4 deletions bundles/io/org.openhab.io.myopenhab/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ output.. = target/classes
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
lib/,\
lib/socket.io-client-0.4.3-SNAPSHOT.jar,\
lib/engine.io-client-0.4.2-SNAPSHOT.jar,\
lib/Java-WebSocket-1.3.0.jar,\
lib/json-20140107.jar
lib/engine.io-client-0.4.2-SNAPSHOT.jar,\
lib/json-20140107.jar,\
lib/socket.io-client-0.4.3-SNAPSHOT.jar
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.openhab.io.myopenhab.internal;

import org.openhab.core.scriptengine.action.ActionDoc;
Expand All @@ -20,11 +19,11 @@
*
* @author Victor Belov
* @since 1.3.0
*
*/

public class MyOpenHAB {

private static final Logger logger = LoggerFactory.getLogger(MyOpenHAB.class);

static MyOpenHABService mMyOpenHABService = null;

/**
Expand All @@ -46,27 +45,27 @@ static public void sendNotification(String userId, String message) {
* @param message the body of the notification
* @param icon name for the notification
* @param severity category for the notification
*
*/
@ActionDoc(text="Sends a push notification to mobile devices of user with userId")
static public void sendNotification(String userId, String message, String icon, String severity) {
logger.debug("sendNotification '{}' to user {}", message, userId);
if (mMyOpenHABService != null)
if (mMyOpenHABService != null) {
mMyOpenHABService.sendNotification(userId, message, icon, severity);
}
}

/**
* Sends an SMS to mobile phone of user
*
* @param phone the user's phone number in international format like +49XXXXXXXXXX
* @param message the body of the sms
*
*/
@ActionDoc(text="Sends an SMS to mobile phone of user")
static public void sendSms(String phone, String message) {
logger.debug("sendSMS()");
if (mMyOpenHABService != null)
if (mMyOpenHABService != null) {
mMyOpenHABService.sendSMS(phone, message);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,28 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.List;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
import org.openhab.io.myopenhab.MyOpenHABService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openhab.core.events.EventPublisher;
import org.openhab.core.items.Item;
import org.openhab.core.items.ItemNotFoundException;
import org.openhab.core.library.items.RollershutterItem;
import org.openhab.core.library.items.SwitchItem;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.UpDownType;
import org.openhab.core.persistence.PersistenceService;
import org.openhab.core.scriptengine.action.ActionService;
import org.openhab.core.types.Command;
import org.openhab.core.types.TypeParser;
import org.openhab.core.persistence.PersistenceService;
import org.openhab.io.myopenhab.MyOpenHABService;
import org.openhab.ui.items.ItemUIRegistry;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This class starts my.openHAB connection service and implements interface to communicate with my.openHAB.
Expand All @@ -51,18 +50,23 @@

public class MyOpenHABServiceImpl implements MyOpenHABService, PersistenceService, ManagedService, ActionService, MyOHClientListener {

public static String myohVersion = "1.7.0.0";
private static Logger logger = LoggerFactory.getLogger(MyOpenHABServiceImpl.class);

public static String myohVersion = "1.7.0.0";
private MyOHClient myOHClient;

private static final String STATIC_CONTENT_DIR = "webapps" + File.separator + "static";
private static final String UUID_FILE_NAME = "uuid";
private static final String SECRET_FILE_NAME = "secret";
private static final String VERSION_FILE_NAME = "version";
private static final String VERSION_FILE_NAME = "version";

private String mMyOHBaseUrl;
private int mLocalPort = 8080;

protected ItemUIRegistry mItemUIRegistry = null;
protected EventPublisher mEventPublisher = null;


public MyOpenHABServiceImpl() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Import-Package: org.apache.commons.lang;version="2.6.0",
Bundle-DocURL: http://www.openhab.org
Service-Component: OSGI-INF/squeezeserver.xml
Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Export-Package: org.cdp1802.xpl; uses:="org.cdp1802.xpl.tracker, org.
Service-Component: OSGI-INF/xpl-*.xml
Bundle-ClassPath: .,
lib/xPL4Java.jar
Bundle-ActivationPolicy: lazy
Loading